<template>
  <div class="login_container">
    <!-- 登陆盒子 -->
    <div class="login_box">
      <!-- 头像 -->
      <div class="avator_box">
        <img src="../assets/logo.png" alt />
      </div>
      <!-- 表单 -->
      <el-form
        :model="loginForm"
        :rules="loginRules"
        ref="loginForm"
        label-width="50px"
        class="login_Form"
      >
        <el-form-item  prop="username">
          <el-input prefix-icon="el-icon-user-solid" v-model="loginForm.username"></el-input>
        </el-form-item>
        <el-form-item  prop="password">
          <el-input prefix-icon="el-icon-lock" type="password" v-model="loginForm.password"></el-input>
        </el-form-item>
        <el-form-item  prop="verifycode">
          <el-input prefix-icon="el-icon-mobile-phone"  v-model="loginForm.verifycode" class="form_verifycode"></el-input>
          <img src="../assets/image/k6kay.gif" alt="验证码" class="verifyImg">
        </el-form-item>
        <el-form-item class="login_btn">
          <el-button type="primary" @click="submitForm('loginForm')">登录</el-button>
          <el-button @click="resetForm('loginForm')">重置</el-button>
        </el-form-item>
      </el-form>
      
    </div>
  </div>
</template>

<script>
export default {
  name:'Login',  
  data() {
    return {
       loginForm: {
          username: '',
          password: '',
          verifycode:'',
        },
        loginRules: {
          username: [
            { required: true, message: '请输入账号', trigger: 'blur' },
            { min: 3, max: 16, message: '长度在 3 到 16 个字符', trigger: 'blur' }
          ],
          password: [
            { required: true, message: '请输入密码', trigger: 'blur' },
            { min: 3, max: 16, message: '长度在 3 到 16 个字符', trigger: 'blur' }
          ],
           verifycode: [
            { required: true, message: '请输入验证码', trigger: 'blur' }
          ],
        }
      
    };
  },
  methods: {
    submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
              //验证表单成功,未写用户名密码认证
            this.$router.push('/main')

          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
  },
};
</script>

<style lang="less" scoped>
.login_container {
  height: 100%;
  background-color: #666;
}
.login_box {
  width: 450px;
  height: 380px;
  background-color: #fff;
  border-radius: 3px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.avator_box {
  width: 130px;
  height: 130px;
  border: 1px solid #eee;
  border-radius: 50%;
  padding: 10px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  margin: -65px auto;
  background-color: #fff;
}
.avator_box img {
  width: 110%;
  height: 110%;
  margin: -7px -10px;
  border-radius: 50%;
  background-color: #eee;
}
.login_Form{
    position: absolute;
    bottom: 0px ;
    width: 90%;
    padding: 0px -20px;
    box-sizing: border-box;
}
.login_btn{
    display: flex;
    justify-content: flex-end;
}
.form_verifycode{
    width: 205px;
    
}
.verifyImg{
    width: 150px;
    height: 40px;
    margin-top: -20px;
    position: relative;
    top: 15px;
}
</style>